home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 April
/
Macworld (1999-04).dmg
/
Shareware World
/
Comms & Internet
/
IP->Clipboard
/
Source
/
IPtoClip.c
next >
Wrap
C/C++ Source or Header
|
1999-01-30
|
1KB
|
92 lines
#include <Scrap.h>
#include <OpenTransport.h>
#include <OpenTptInternet.h>
#include <OSUtils.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <Sound.h>
void main( void )
{
OSStatus *err;
char ip[15];
unsigned short counter;
Boolean end = false;
InetInterfaceInfo *info;
err = malloc(sizeof(OSStatus));
info = malloc(sizeof(InetInterfaceInfo));
//InitOT
if( InitOpenTransport() != kOTNoError )
{
SysBeep(30);
ExitToShell();
}
OTOpenInternetServices ( kDefaultInternetServicesPath, 0, err);
//beep at user if there is an error, and quit
if( *err != kOTNoError )
{
SysBeep(30);
SysBeep(30);
ExitToShell();
}
//Get your IP and put it in the string IP.
OTInetGetInterfaceInfo( info, kDefaultInetInterface );
OTInetHostToString( info->fAddress, ip );
counter = 0;
//make sure there are no weird chars
while( !end )
{
switch( ip[counter] )
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '.':
counter++;
if( counter == 15 )
end = true;
break;
default:
end = true;//so you will end the counter so it will end the for statement, and then you will know the string length is 1 less then the counter.
break;
}
}
ZeroScrap();
PutScrap( counter, 'TEXT', ip );
ExitToShell();
}